<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const arr1 = [1,3,5,7,9]
        const arr2 = [2,4,6,8,10]
        console.log("展开数组",...arr1)
        const arr3 = [...arr1,...arr2]
        console.log("arr3 = ", arr3)

        function sum(...num){
            return num.reduce((preValue, currentValue) => {
                return preValue + currentValue
            })
        }
        console.log(sum(1,2,3,4,5,6,7))

        // 构造字面量时使用展开语法
        const obj1 = {
            name:"小王",
            age:"17",
            sex:"男"
        }
        // console.log(...obj1) // 报错 展开运算符不能展开对象
        const obj2 = {...obj1}
        console.log("展开对象",obj2)
        // 合并
        const obj3 = {...obj1,name:"jack",adress:"地球"}
        
        console.log(obj3)
    </script>
</body>
</html>